﻿using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;

namespace VSOfflineMaker
{
	// Token: 0x02000007 RID: 7
	public class MessageBoxEx
	{
		// Token: 0x0600002C RID: 44 RVA: 0x00004B2C File Offset: 0x00002D2C
		public static DialogResult Show(string text)
		{
			MessageBoxEx.Initialize();
			return MessageBox.Show(text);
		}

		// Token: 0x0600002D RID: 45 RVA: 0x00004B39 File Offset: 0x00002D39
		public static DialogResult Show(string text, string caption)
		{
			MessageBoxEx.Initialize();
			return MessageBox.Show(text, caption);
		}

		// Token: 0x0600002E RID: 46 RVA: 0x00004B47 File Offset: 0x00002D47
		public static DialogResult Show(string text, string caption, MessageBoxButtons buttons)
		{
			MessageBoxEx.Initialize();
			return MessageBox.Show(text, caption, buttons);
		}

		// Token: 0x0600002F RID: 47 RVA: 0x00004B56 File Offset: 0x00002D56
		public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
		{
			MessageBoxEx.Initialize();
			return MessageBox.Show(text, caption, buttons, icon);
		}

		// Token: 0x06000030 RID: 48 RVA: 0x00004B66 File Offset: 0x00002D66
		public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defButton)
		{
			MessageBoxEx.Initialize();
			return MessageBox.Show(text, caption, buttons, icon, defButton);
		}

		// Token: 0x06000031 RID: 49 RVA: 0x00004B78 File Offset: 0x00002D78
		public static DialogResult Show(string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defButton, MessageBoxOptions options)
		{
			MessageBoxEx.Initialize();
			return MessageBox.Show(text, caption, buttons, icon, defButton, options);
		}

		// Token: 0x06000032 RID: 50 RVA: 0x00004B8C File Offset: 0x00002D8C
		public static DialogResult Show(IWin32Window owner, string text)
		{
			MessageBoxEx._owner = owner;
			MessageBoxEx.Initialize();
			return MessageBox.Show(owner, text);
		}

		// Token: 0x06000033 RID: 51 RVA: 0x00004BA0 File Offset: 0x00002DA0
		public static DialogResult Show(IWin32Window owner, string text, string caption)
		{
			MessageBoxEx._owner = owner;
			MessageBoxEx.Initialize();
			return MessageBox.Show(owner, text, caption);
		}

		// Token: 0x06000034 RID: 52 RVA: 0x00004BB5 File Offset: 0x00002DB5
		public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons)
		{
			MessageBoxEx._owner = owner;
			MessageBoxEx.Initialize();
			return MessageBox.Show(owner, text, caption, buttons);
		}

		// Token: 0x06000035 RID: 53 RVA: 0x00004BCB File Offset: 0x00002DCB
		public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
		{
			MessageBoxEx._owner = owner;
			MessageBoxEx.Initialize();
			return MessageBox.Show(owner, text, caption, buttons, icon);
		}

		// Token: 0x06000036 RID: 54 RVA: 0x00004BE3 File Offset: 0x00002DE3
		public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defButton)
		{
			MessageBoxEx._owner = owner;
			MessageBoxEx.Initialize();
			return MessageBox.Show(owner, text, caption, buttons, icon, defButton);
		}

		// Token: 0x06000037 RID: 55 RVA: 0x00004BFD File Offset: 0x00002DFD
		public static DialogResult Show(IWin32Window owner, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defButton, MessageBoxOptions options)
		{
			MessageBoxEx._owner = owner;
			MessageBoxEx.Initialize();
			return MessageBox.Show(owner, text, caption, buttons, icon, defButton, options);
		}

		// Token: 0x06000038 RID: 56
		[DllImport("user32.dll")]
		private static extern bool GetWindowRect(IntPtr hWnd, ref Rectangle lpRect);

		// Token: 0x06000039 RID: 57
		[DllImport("user32.dll")]
		private static extern int MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);

		// Token: 0x0600003A RID: 58
		[DllImport("User32.dll")]
		public static extern UIntPtr SetTimer(IntPtr hWnd, UIntPtr nIDEvent, uint uElapse, MessageBoxEx.TimerProc lpTimerFunc);

		// Token: 0x0600003B RID: 59
		[DllImport("User32.dll")]
		public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);

		// Token: 0x0600003C RID: 60
		[DllImport("user32.dll")]
		public static extern IntPtr SetWindowsHookEx(int idHook, MessageBoxEx.HookProc lpfn, IntPtr hInstance, int threadId);

		// Token: 0x0600003D RID: 61
		[DllImport("user32.dll")]
		public static extern int UnhookWindowsHookEx(IntPtr idHook);

		// Token: 0x0600003E RID: 62
		[DllImport("user32.dll")]
		public static extern IntPtr CallNextHookEx(IntPtr idHook, int nCode, IntPtr wParam, IntPtr lParam);

		// Token: 0x0600003F RID: 63
		[DllImport("user32.dll")]
		public static extern int GetWindowTextLength(IntPtr hWnd);

		// Token: 0x06000040 RID: 64
		[DllImport("user32.dll")]
		public static extern int GetWindowText(IntPtr hWnd, StringBuilder text, int maxLength);

		// Token: 0x06000041 RID: 65
		[DllImport("user32.dll")]
		public static extern int EndDialog(IntPtr hDlg, IntPtr nResult);

		// Token: 0x06000043 RID: 67 RVA: 0x00004C36 File Offset: 0x00002E36
		private static void Initialize()
		{
			if (MessageBoxEx._hHook != IntPtr.Zero)
			{
				throw new NotSupportedException("multiple calls are not supported");
			}
			if (MessageBoxEx._owner != null)
			{
				MessageBoxEx._hHook = MessageBoxEx.SetWindowsHookEx(12, MessageBoxEx._hookProc, IntPtr.Zero, AppDomain.GetCurrentThreadId());
			}
		}

		// Token: 0x06000044 RID: 68 RVA: 0x00004C78 File Offset: 0x00002E78
		private static IntPtr MessageBoxHookProc(int nCode, IntPtr wParam, IntPtr lParam)
		{
			if (nCode < 0)
			{
				return MessageBoxEx.CallNextHookEx(MessageBoxEx._hHook, nCode, wParam, lParam);
			}
			MessageBoxEx.CWPRETSTRUCT cwpretstruct = (MessageBoxEx.CWPRETSTRUCT)Marshal.PtrToStructure(lParam, typeof(MessageBoxEx.CWPRETSTRUCT));
			IntPtr hHook = MessageBoxEx._hHook;
			if (cwpretstruct.message == 5U)
			{
				try
				{
					MessageBoxEx.CenterWindow(cwpretstruct.hwnd);
				}
				finally
				{
					MessageBoxEx.UnhookWindowsHookEx(MessageBoxEx._hHook);
					MessageBoxEx._hHook = IntPtr.Zero;
				}
			}
			return MessageBoxEx.CallNextHookEx(hHook, nCode, wParam, lParam);
		}

		// Token: 0x06000045 RID: 69 RVA: 0x00004CF8 File Offset: 0x00002EF8
		private static void CenterWindow(IntPtr hChildWnd)
		{
			Rectangle rectangle = new Rectangle(0, 0, 0, 0);
			MessageBoxEx.GetWindowRect(hChildWnd, ref rectangle);
			int num = rectangle.Width - rectangle.X;
			int num2 = rectangle.Height - rectangle.Y;
			Rectangle rectangle2 = new Rectangle(0, 0, 0, 0);
			MessageBoxEx.GetWindowRect(MessageBoxEx._owner.Handle, ref rectangle2);
			Point point = new Point(0, 0);
			point.X = rectangle2.X + (rectangle2.Width - rectangle2.X) / 2;
			point.Y = rectangle2.Y + (rectangle2.Height - rectangle2.Y) / 2;
			Point point2 = new Point(0, 0);
			point2.X = point.X - num / 2;
			point2.Y = point.Y - num2 / 2;
			point2.X = ((point2.X < 0) ? 0 : point2.X);
			point2.Y = ((point2.Y < 0) ? 0 : point2.Y);
			MessageBoxEx.MoveWindow(hChildWnd, point2.X, point2.Y, num, num2, false);
		}

		// Token: 0x0400001C RID: 28
		private static IWin32Window _owner;

		// Token: 0x0400001D RID: 29
		private static MessageBoxEx.HookProc _hookProc = new MessageBoxEx.HookProc(MessageBoxEx.MessageBoxHookProc);

		// Token: 0x0400001E RID: 30
		private static IntPtr _hHook = IntPtr.Zero;

		// Token: 0x0400001F RID: 31
		public const int WH_CALLWNDPROCRET = 12;

		// Token: 0x02000010 RID: 16
		// (Invoke) Token: 0x06000071 RID: 113
		public delegate IntPtr HookProc(int nCode, IntPtr wParam, IntPtr lParam);

		// Token: 0x02000011 RID: 17
		// (Invoke) Token: 0x06000075 RID: 117
		public delegate void TimerProc(IntPtr hWnd, uint uMsg, UIntPtr nIDEvent, uint dwTime);

		// Token: 0x02000012 RID: 18
		public enum CbtHookAction
		{
			// Token: 0x04000033 RID: 51
			HCBT_MOVESIZE,
			// Token: 0x04000034 RID: 52
			HCBT_MINMAX,
			// Token: 0x04000035 RID: 53
			HCBT_QS,
			// Token: 0x04000036 RID: 54
			HCBT_CREATEWND,
			// Token: 0x04000037 RID: 55
			HCBT_DESTROYWND,
			// Token: 0x04000038 RID: 56
			HCBT_ACTIVATE,
			// Token: 0x04000039 RID: 57
			HCBT_CLICKSKIPPED,
			// Token: 0x0400003A RID: 58
			HCBT_KEYSKIPPED,
			// Token: 0x0400003B RID: 59
			HCBT_SYSCOMMAND,
			// Token: 0x0400003C RID: 60
			HCBT_SETFOCUS
		}

		// Token: 0x02000013 RID: 19
		public struct CWPRETSTRUCT
		{
			// Token: 0x0400003D RID: 61
			public IntPtr lResult;

			// Token: 0x0400003E RID: 62
			public IntPtr lParam;

			// Token: 0x0400003F RID: 63
			public IntPtr wParam;

			// Token: 0x04000040 RID: 64
			public uint message;

			// Token: 0x04000041 RID: 65
			public IntPtr hwnd;
		}
	}
}
